package com.hl.component;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.FrameLayout;


/**
 * 
 * @ClassName:     LoadingView.java
 * @Description:   加载时候显示UI
 * 
 * @author         heliang
 * @version        V1.0  
 * @Date           2013-10-13 下午6:36:03
 */
public abstract class LoadingView extends FrameLayout {
	protected Bitmap bitmap;
	protected boolean isDownload = false;
	protected Context mContext;

	// protected Bitmap bitmap;

	public LoadingView(Context context) {
		super(context);

	}

	public LoadingView(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public void setImageViewSource(Bitmap bitmap) {
		this.bitmap = bitmap;
		initUI(bitmap);
	}

	public Bitmap getBitmap() {
		return this.bitmap;
	}

	public void setImageViewSource(Drawable drawable) {
		// this.bitmap = bitmap;
		initUI(drawable);
	}

	// public Bitmap getBitmap(){
	// return this.bitmap;
	// }

	/**
	 * 初始化UI
	 */
	protected abstract void initUI(Bitmap bitmap);

	protected abstract void initUI(Drawable drawable);

	protected class AppFrameLayout extends FrameLayout {

		public AppFrameLayout(Context context) {
			super(context);
			// TODO Auto-generated constructor stub
		}

		@Override
		public boolean dispatchTouchEvent(MotionEvent event) {
			return true;
		}

		// @Override
		// public boolean onTouchEvent(MotionEvent event) {
		// return false;
		// }

	}

	public boolean isDownload() {
		return isDownload;
	}

	public void setDownload(boolean isDownload) {
		this.isDownload = isDownload;
	}
}